home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / tsr25src.arc / MARK.ASM < prev    next >
Encoding:
Assembly Source File  |  1987-06-02  |  5.7 KB  |  161 lines

  1. ;==============================================================================
  2. ; MARK.ASM - mark a position in memory,
  3. ;            above which TSRs will later be cleared by RELEASE.COM
  4. ;            MARK can be called multiple times, each RELEASE will clear
  5. ;            above the last MARK called.
  6. ; If MARK is called with something on the command line, that text will
  7. ; be stored in the program segment prefix at offset 80H, where it is
  8. ; later accessible to RELEASE for a "named" release.
  9. ;==============================================================================
  10. ; written for MASM (MicroSoft Assembler version 4)
  11. ; by Kim Kokkonen, TurboPower Software
  12. ; telephone: 408-438-8608, Compuserve 72457,2131
  13. ;==============================================================================
  14. ; VERSION 1.4  2/23/86
  15. ;   This version also stores the EMS page map so that RELEASE can release
  16. ;   READY! and any future resident programs using expanded memory
  17. ; VERSION 1.5  2/28/86
  18. ;   to keep consistent with MAPMEM and RELEASE
  19. ; VERSION 1.6  3/8/86
  20. ;   store all 256 interrupts, but only 32 EMS blocks
  21. ; VERSION 1.7  4/1/86
  22. ;   close the EMS handle opened to avoid using up a DOS handle
  23. ; VERSION 1.8  4/20/86
  24. ;   to keep consistent with MAPMEM and RELEASE
  25. ; VERSION 1.9  5/22/86
  26. ;   to keep consistent with MAPMEM and RELEASE
  27. ; VERSION 2.0  5/26/86
  28. ;   to keep consistent with MAPMEM and RELEASE
  29. ; VERSION 2.1  7/18/86
  30. ;   to keep consistent with RELEASE
  31. ; VERSION 2.2  3/4/87
  32. ;   add save area for BIOS data areas
  33. ;     40:A8 (8 bytes for EGA)
  34. ;     40:F0 (16 bytes for interapplications communications)
  35. ; VERSION 2.3  5/1/87
  36. ;   convert to use MASM
  37. ;   chop off unused portion of EMS page map when going resident
  38. ;   modify so that the data areas are not part of the COM file
  39. ; VERSION 2.4  5/17/87
  40. ;   for consistency with RELEASE
  41. ; VERSION 2.5  6/2/87
  42. ;   add version checking between MARK and RELEASE
  43. ;==============================================================================
  44.  
  45. Cseg      segment public para
  46.           assume  cs:Cseg, ds:Cseg, es:nothing
  47.  
  48.           org     100H
  49. comentry: jmp     doit
  50.  
  51. ;put the following in the MAP file
  52. public idstr,vector,egasav,intcom,emscnt,emsmap
  53.  
  54. idstr  db      'M2.5 PARAMETER BLOCK FOLLOWS' ;used to find this TSR
  55.  
  56. ;**** the following will be overwritten by the vector table image *************
  57. ;success message and version number
  58. didit  db      13,10,'MARK 2.5 - Marked current memory position',13,10,36
  59. ;file name for testing EMS presence
  60. emsnm  db      'EMMXXXX0',0
  61. ;******************************************************************************
  62.  
  63. vector equ     0120H           ;offset in code seg where vector table is copied
  64. veclen equ     0400H           ;1024 bytes for vectors
  65. egasav equ     vector+veclen
  66. egalen equ     8               ;8 bytes for EGA save area
  67. intcom equ     egasav+egalen
  68. intlen equ     10H             ;16 bytes for interapps communication area
  69. emscnt equ     intcom+intlen
  70. emsmap equ     emscnt+2
  71.  
  72. newloc equ     emsmap+100H     ;location of relocated code
  73.  
  74. ;*****************************************************************************
  75.  
  76. doit   proc    near
  77.  
  78. ;relocate ourselves out of the way
  79.        mov     di,newloc
  80.        push    di                    ;will act as a return address
  81.        mov     si,offset pmess
  82.        mov     cx,lastcode-pmess
  83.        cld
  84.        rep     movsb
  85.        ret                          ;"return" to the relocated code
  86.  
  87. ;print message
  88. pmess:
  89.        mov     dx,offset didit
  90.        mov     ah,9
  91.        int     21H             ;write success message
  92.  
  93. ;determine whether EMS is present
  94.        mov     dx,offset emsnm
  95.        mov     ax,3D00H
  96.        int     21H
  97.        jnc     emspres           ;ems driver installed
  98.        xor     bx,bx
  99.        jmp     short stocnt
  100.  
  101. ;EMS present, close the open handle first
  102. emspres:
  103.        mov     bx,ax
  104.        mov     ah,3EH
  105.        int     21H
  106.  
  107. ;store the EMS page map
  108.        mov     ah,4DH
  109.        mov     di,emsmap
  110.        xor     bx,bx           ;required by some versions of EMM
  111.        cld                     ;required by some versions of EMM
  112.        int     67H
  113.  
  114. ;store the number of active handles
  115. stocnt:
  116.        mov     di,emscnt
  117.        mov     [di],bx          ;count of active handles
  118.  
  119. ;store the interrupt vector table (overwrites initial messages)
  120.        xor     ax,ax
  121.        mov     ds,ax            ;source address segment 0
  122.        assume  ds:nothing
  123.        xor     si,si            ;offset 0
  124.        mov     di,vector        ;destination offset, es=cs already
  125.        mov     cx,veclen shr 1  ;count of words to store
  126.        rep     movsw            ;copy vectors to our table
  127.  
  128. ;store the EGA save area
  129.        mov     ax,40H
  130.        mov     ds,ax            ;point to BIOS data area
  131.        mov     si,00A8H         ;EGA save area pointer
  132.        mov     di,egasav
  133.        mov     cx,egalen shr 1
  134.        rep     movsw            ;copy information to our save area
  135.  
  136. ;store the interapplications communication area
  137.        mov     si,00F0H         ;interapps communication area address
  138.        mov     di,intcom
  139.        mov     cx,intlen shr 1
  140.        rep     movsw            ;copy information to our save area
  141.  
  142. ;terminate and stay resident
  143. gores:
  144.        mov     dx,emsmap       ;start at base of ems map
  145.        mov     di,emscnt
  146.        mov     bx,cs:[di]      ;count of active handles
  147.        shl     bx,1
  148.        shl     bx,1            ;multiply EMS handle count by 4
  149.        add     dx,bx
  150.        add     dx,000FH        ;round up for paragraphs
  151.        mov     cl,4
  152.        shr     dx,cl           ;convert to paragraphs
  153.        mov     ax,3100H
  154.        int     21H             ;terminate but stay resident
  155.  
  156. lastcode:
  157. doit    endp
  158.  
  159. Cseg    ends
  160.         end     ComEntry
  161.